﻿@model ElectronicDiary.Models.Teacher.GradesViewModel
@using System.Data;

@{
    ViewBag.Title = "Oceny";
}

<!--[if IE]>
   <style>
      .rotate_text
      {
         filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
      }
   </style>
<![endif]-->
<!--[if !IE]><!-->
   <style>
      .rotate_text
      {
        color:#333;
	    border:0px solid red;
	    writing-mode:tb-rl;
	    -webkit-transform:rotate(270deg);
	    -moz-transform:rotate(270deg);
	    -o-transform: rotate(270deg);
        white-space:nowrap;
	    display:block;
	    bottom:0;
	    width:20px;
	    height:20px;
	    font-family: ‘Trebuchet MS’, Helvetica, sans-serif;
	    font-size:14px;
	    font-weight:normal;
	    text-shadow: 0px 0px 1px #333;
    }
   </style>
<!--<![endif]-->

   <style>  
      table
      {
         border: 1px solid black;
         table-layout: fixed;
         width: 69px; /*Table width must be set or it wont resize the cells*/
      }
      th, td 
      {
          border: 1px solid black;
          width: 33px;
      }
      .rotated_cell
      {
         height:150px;
         vertical-align:bottom;
         padding: 0px;
         padding-bottom: 5px;
      }
    #oceny input[type="text"] {
        border: 1px solid #ccc;
        padding: 2px;
        font-size: 1.2em;
        color: #444;
        width: 17px;
    }
   </style>

<h2>Oceny</h2>

@using (Ajax.BeginForm("GradeValid", new AjaxOptions { OnSuccess = "onSuccess", HttpMethod = "Post", UpdateTargetId = "NGValid", InsertionMode = InsertionMode.Replace }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>@Model.Subject - klasa @Model.Class</legend>

        @Html.HiddenFor(n => n.Class)
        @Html.HiddenFor(n => n.Subject) 
        @Html.HiddenFor(n => n.IDSubject)   

        <table id="oceny">
            <thead>
                <tr>
                    @Html.DisplayFor(x => x.Columns)
                </tr>
            </thead>
            <tbody>
                @Html.DisplayFor(x => x.Rows)
            </tbody>
        </table>
        
        @Html.ValidationMessageFor(n => n.Rows.First().Values.First().Value)
        <br /><br />
        <div style="text-align:center;">
            Opis nowej oceny:
            @Html.EditorFor(n => n.NewGrade, new { ID = "NewGrade" }) 
            @Html.ValidationMessageFor(n=>n.NewGrade)
            <div id="NGValid"><br /></div>
        </div>
        <div style="text-align:right; margin-right:20%;">
            <p><input type="submit" value="Zapisz" /></p>                      
        </div>
    </fieldset>
}

<div>
    @Html.ActionLink("Powrót do listy", "Panel")
</div>


<script type="text/javascript">
    var onSuccess = function (result) {
        if (result.url) {
            // if the server returned a JSON object containing an url 
            // property we redirect the browser to that url
            window.location.href = result.url;
        }
    }
</script>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

   